<template>
  <div>
    <el-card shadow="never">
      <h3>编辑公告</h3>
    </el-card>
    <br>
    <el-card shadow="never">
      <el-form label-width="80px">
        <el-form-item label="标题">
          <el-input v-model="form.title" placeholder="请输入标题" clearable />
        </el-form-item>
        <el-form-item label="内容">
          <tinymce v-model="form.content" />
        </el-form-item>
        <el-form-item label="">
          <el-button type="primary" @click="editBtn">更新</el-button>
          <el-button type="primary" @click="$router.go(-1)">返回</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
import Tinymce from '@/components/Tinymce/index.vue'
import * as noticeApi from '@/api/notice'
export default {
  name: '',
  components: {
    Tinymce
  },

  data() {
    return {
      form: {}
    }
  },
  created() {
    noticeApi.getById(this.$route.params.id).then(resp => {
      this.form = resp.data
    })
  },
  methods: {
    editBtn() {
      noticeApi.update(this.form).then(resp => {
        this.$notifySuccess('更新成功')
      })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
